#region Microsoft Public License
/*
 * (c) Copyright Chenjun Wu. http://utablesdk.codeplex.com
 * 
 * This source is subject to the Microsoft Public License (Ms-PL).
 * Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
 * All other rights reserved.
 */
#endregion

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using UTable.Input;
using UTable.Input.MultiTouch;
using UTable.Objects;
using UTable.Objects.Controls;

namespace UTable.Objects
{
    /// <summary>
    /// Interaction logic for UOpenFileDialog.xaml
    /// </summary>
    public partial class UOpenFileDialog : UObject
    {
        public UOpenFileDialog()
        {
            InitializeComponent();
        }

        private UOpenFileDialogModel model = new UOpenFileDialogModel();

        public override void InitializeModel(object model)
        {
            if (model is UOpenFileDialogModel)
            {
                this.model = model as UOpenFileDialogModel;
            }
        }

        public override object GetModel()
        {
            return model;
        }

        private void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            model.ShouldOpen = true;
            if (Explorer.SelectedFiles.Count > 0)
                model.OpenFilePath = Explorer.SelectedFiles[0].FilePath;
            Close();
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            model.ShouldOpen = false;
            Close();
        }
    }

    public class UOpenFileDialogModel
    {
        public bool ShouldOpen = false;

        public String OpenFilePath = String.Empty;
    }
}
